<?php
/** 
 * Plugin 'rdt_url' for the 'ameos_formidable' extension.
 *
 * @author	Jerome Schneider <typo3dev@ameos.com>
 */


class tx_rdturl extends formidable_mainrenderlet {
	
	function _render() {

		$value = $this->getValue();
		$label = $this->getLabel();
		$value = $this->oForm->_getLLLabel($value);

		$value = htmlspecialchars($value);
		
		return $this->_displayLabel($label) . "<input type=\"text\" name=\"" . $this->_getElementHtmlName() . "\" id=\"" . $this->_getElementHtmlId() . "\" value=\"" . $value . "\"" . $this->_getAddInputParams() . " />";
	}

	function _getHumanReadableValue($data) {
		if(($sUrl = trim($data)) != "") {
			
			$aUrl = parse_url($sUrl);
			
			if(!array_key_exists("scheme", $aUrl)) {
				$sUrl = "http://" . $sUrl;
			}
			
			return "<a href=\"" . $sUrl . "\" target=\"_blank\">" . $sUrl . "</a>";
		}

		return "";
	}
}


	if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/base/rdt_url/api/class.tx_rdturl.php"])	{
		include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/base/rdt_url/api/class.tx_rdturl.php"]);
	}

?>